package com.heimali.happyreader.model;

import java.util.ArrayList;
import java.util.Collection;
import java.util.List;

import org.apache.http.message.BasicNameValuePair;

@SuppressWarnings("rawtypes")
public class Array {

	public ArrayList<KVPair> list = new ArrayList<KVPair>();

	// private int size = 0;

	public Array(BasicNameValuePair... args) {
		for (BasicNameValuePair pair : args) {
			list.add(new KVPair<String, String>(pair.getName(), pair.getValue()));
		}
	}

	public Array(KVPair... args) {
		for (KVPair item : args) {
			list.add(item);
		}
	}

	public Array(String[]... args) {
		for (String[] item : args) {
			list.add(new KVPair<String, String>(item[0], item[1]));
		}
	}

	public void add(int location, KVPair object) {
		// TODO Auto-generated method stub
		list.add(location, object);
	}

	public boolean add(KVPair object) {
		return list.add(object);
	}

	@SuppressWarnings("unchecked")
	public boolean addAll(int location, Collection collection) {
		return list.addAll(location, collection);
	}

	@SuppressWarnings("unchecked")
	public boolean addAll(Collection collection) {
		return list.addAll(collection);
	}

	public void clear() {
		list.clear();
	}

	public boolean contains(KVPair object) {
		return list.contains(object);
	}

	public boolean containsAll(Collection collection) {
		return list.containsAll(collection);
	}

	public KVPair get(int location) {
		if (location < 0 && location > (size() - 1)) {
			return null;
		}
		return list.get(location);
	}

	public Object set(int location, KVPair object) {
		return list.set(location, object);
	}

	public int indexOf(KVPair object) {
		return list.indexOf(object);
	}

	public boolean isEmpty() {
		return list.isEmpty();
	}

	public int lastIndexOf(KVPair object) {
		return list.lastIndexOf(object);
	}

	public KVPair remove(int location) {
		list.remove(location);
		return null;
	}

	public boolean remove(KVPair object) {
		return list.remove(object);
	}

	public boolean removeAll(Collection collection) {
		return list.removeAll(collection);
	}

	public int size() {
		return list.size();
	}

	public List subList(int start, int end) {
		return list.subList(start, end);
	}
}
